package com.mjh.controller;

import com.github.pagehelper.PageInfo;
import com.mjh.bean.ActivityRemark;
import com.mjh.model.R;
import com.mjh.service.ActivityRemarkService;
import com.mjh.vo.ActivityRemarkVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 市场活动备注接口管理
 */
@RestController
@RequestMapping("/api/activity/remark")
public class ActivityRemarkController {
    @Autowired
    private ActivityRemarkService activityRemarkService;
    /**
     * 根据市场活动标识分页查询市场活动备注列表
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/page/{activityId}")
    public R<PageInfo<ActivityRemarkVo>> loadActivityRemarkPage(@PathVariable Integer activityId,
                                                                @RequestParam(required = false,defaultValue = "10") Integer size,
                                                                @RequestParam("current") Integer current) {
        PageInfo<ActivityRemarkVo> pageInfo = activityRemarkService.queryActivityRemarkInfoPage(current,size,activityId);
        return R.OK(pageInfo);
    }

    /**
     * 增加活动备注
     * @param
     * @return
     */
    @PostMapping("/add")
    public R<String> saveActivityRemark(@RequestBody ActivityRemark activityRemark) {
       Boolean result = activityRemarkService.saveActivityRemark(activityRemark);
        return R.HANDLER(result);
    }

    /**
     * 删除活动备注
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R<String> removeActivityRemark(@PathVariable Integer id) {
        Boolean result = activityRemarkService.removeActivityRemark(id);
        return R.HANDLER(result);
    }
    /**
     * 根据活动备注标识查询活动备注
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    public R<ActivityRemark> queryActivityRemarkById(@PathVariable Integer id) {
        ActivityRemark activityRemark = activityRemarkService.queryActivityRemarkById(id);
        return R.OK(activityRemark);
    }
    /**
     * 修改活动备注
     * @param
     * @return
     */
    @PutMapping("/modify")
    public R<String> modifyActivityRemark(@RequestBody ActivityRemark activityRemark) {
        Boolean result = activityRemarkService.modifyActivityRemark(activityRemark);
        return R.HANDLER(result);
    }
}
